home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cc04.arc / SCRNMISC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-03-15  |  4.6 KB  |  173 lines

  1.  
  2. /**
  3. * These are functions written using the Lattice 2.12 compiler
  4. * that set, move and write to the CRT. Standard DOS Calls are
  5. * used. This is extracted from a larger program
  6. *
  7. * Garth Kennedy    Hinsdale, Ill  9 Nov 1984
  8. **/
  9.  
  10. #include "_main.c"
  11. int curpos[6];                 /* cursor position array */
  12. /**
  13. * curpos[0] - text row,              curpos[3] - dot row    
  14. * curpos[1] - text column            curpos[4] - dot column 
  15. * curpos[2] - display page number    curpos[5] - dot color  
  16. **/
  17.  
  18. /**
  19. * scrnclr()
  20. *
  21. * Clear screen    regardless of mode
  22. *
  23. * Garth Kennedy  29 Oct 1984
  24. **/
  25.  
  26. scrnclr()
  27. {
  28.     int intno = 0x10;            /* interrupt to VIDEO_IO */
  29.     union REGS inregs;           /* input regs */
  30.     union REGS outregs;          /* output regs */
  31.  
  32.     inregs.h.ah = 0x0F;          /* return current video state */
  33.     int86(intno,&inregs,&outregs);
  34.  
  35.     inregs.h.ah = 0x00;          /* set display mode */
  36.     inregs.h.al = outregs.h.al;    /* to current mode */
  37.  
  38.     int86(intno,&inregs,&outregs);
  39.     
  40.     return;
  41. }
  42. /**/
  43.  
  44. /**
  45. * scrnpos(x,y)
  46. *
  47. * Move the cursor the the row, column set by x,y
  48. *
  49. * Garth Kennedy  29 Oct 1984
  50. **/
  51.  
  52. scrnpos(x,y)
  53. int x;          /* row */
  54. int y;          /* column */
  55. {
  56.     int intno = 0x10;            /* interrupt to VIDEO_IO */
  57.     union REGS inregs;           /* input regs */
  58.     union REGS outregs;          /* output regs */
  59.  
  60.     inregs.h.ah = 0x02;          /* set cursor position */
  61.     inregs.h.dh = x;             /* row to go to */
  62.     inregs.h.dl = y;             /* column to go to */
  63.     inregs.h.bh = 0x00;          /* page 0 */
  64.  
  65.     int86(intno,&inregs,&outregs);
  66.     
  67.     return;
  68. }
  69. /**/
  70. /**
  71. *  scrnwhr(curpos)
  72. * return position (row/column) and page number
  73. * curpos [0] - row, curpos[1] - column, curpos[2] - page number
  74. * curpos[3] - dot row , curpos[4] - dot column, curpos[5] - color 
  75. * Garth Kennedy  30 Oct 1984
  76. **/
  77.  
  78. scrnwhr(curpos)
  79. int curpos[];
  80. {
  81.     int intno = 0x10;            /* interrupt to VIDEO_IO */
  82.     union REGS inregs;           /* input regs */
  83.     union REGS outregs;          /* output regs */
  84.  
  85.     inregs.h.ah = 0x0F;          /* return current video state */
  86.     int86(intno,&inregs,&outregs);
  87.     curpos[2] = outregs.h.bh;           /* current page */
  88.     
  89.     inregs.h.bh = outregs.h.bh;  /* move current page */
  90.     inregs.h.ah = 0x03;          /* read cursor position */
  91.     int86(intno,&inregs,&outregs);
  92.     curpos[0] = outregs.h.dh;            /* row */
  93.     curpos[1] = outregs.h.dl;            /* column */
  94.     return;
  95. }
  96. /**/
  97. /**
  98. * setcrt(al)
  99. *
  100. * Set the CRT display mode
  101. *  al = 0    40X25 BW Text       al = 4  320X200 Color Graphics
  102. *  al = 1    40X25 Color Text    al = 5  320X200 BW Graphics
  103. *  al = 2    80X25 BW Text       al = 6  640X200 BW Graphics
  104. *  al = 3    80X25 Color Text    
  105. *
  106. * Garth Kennedy  9 Nov 1984
  107. **/
  108. setcrt(al)
  109. int al;
  110. {
  111.     int intno = 0x10;            /* interrupt to VIDEO_IO */
  112.     union REGS inregs;           /* input regs */
  113.     union REGS outregs;          /* output regs */
  114.  
  115.     inregs.h.ah = 0x00;          /* set display mode */
  116.     inregs.h.al = al;            /* to requested mode */
  117.  
  118.     int86(intno,&inregs,&outregs);
  119.     
  120.     return;
  121. }
  122. /**/
  123. /**
  124. * grfpos(dx,dy,l)
  125. *
  126. * position the graphics "cursor" and turn to dot at that point to
  127. * the color given by l.- dx - row, dy - column
  128. *  !!! This does nothing with the text cursor  !!!
  129. *  Garth Kennedy  9 Nov 1984
  130. **/
  131.  
  132. grfpos(dx,dy,l)
  133. int dx,dy,l;
  134. {
  135.     int intno = 0x10;            /* interrupt to VIDEO_IO */
  136.     union REGS inregs;           /* input regs */
  137.     union REGS outregs;          /* output regs */
  138.  
  139.     inregs.h.ah = 0x0C;          /* write dot */
  140.     inregs.x.dx = dx;            /* row to go to */
  141.     inregs.x.cx = dy;            /* column to go to */
  142.     inregs.h.al = l;             /* color value */
  143.  
  144.     int86(intno,&inregs,&outregs);
  145.     
  146.     return;
  147. }
  148.  
  149. /**
  150. *  grfwhr(curpos)
  151. * return color given dot position (row/column) 
  152. * curpos [0] - row, curpos[1] - column, curpos[2] - page number
  153. * curpos[3] - dot row , curpos[4] - dot column, curpos[5] - color 
  154. * Garth Kennedy  9 Nov 1984
  155. **/
  156.  
  157. grfwhr(curpos)
  158. int curpos[];
  159. {
  160.     int intno = 0x10;            /* interrupt to VIDEO_IO */
  161.     union REGS inregs;           /* input regs */
  162.     union REGS outregs;          /* output regs */
  163.     
  164.     inregs.x.dx = curpos[3];     /* dot row */
  165.     inregs.x.cx = curpos[4];     /* dot column */
  166.     inregs.h.ah = 0x0D;          /* read dot color */
  167.     int86(intno,&inregs,&outregs);
  168.     curpos[5] = outregs.h.al;    /* pull out color of dot */
  169.     return;
  170. }
  171. ot c